package com.linln.wtp.controller.insuranceoffer;

import com.linln.common.vo.JsonResult;
import com.linln.component.wtpshiro.annotation.UserLoginToken;
import com.linln.modules.insurance.domain.InsuranceOffer;
import com.linln.modules.insurance.service.InsuranceOfferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : pengliang
 * @version V1.0
 * @Project: timo
 * @Package com.linln.wtp.controller.insuranceoffer
 * @Descriptio /**
 * @Project: timo
 * @Package com.linln.wtp.controller.insuranceoffer
 * @Description: TODO
 * @date Date : 2020年12月29日 14:27
 */
@RestController
@RequestMapping("insuranceOffer")
@EnableConfigurationProperties(InsuranceProperties.class)
public class InsuranceOfferController {

    @Autowired
    private InsuranceOfferService insuranceOfferService;

    //保险公司列表属性
    @Autowired
    private InsuranceProperties insuranceProperties;

    /**
     * 添加报价信息
     * @param insuranceOffer
     * @return
     */
    @PostMapping
    @UserLoginToken
    public JsonResult addInsuranceOffer(InsuranceOffer insuranceOffer) {
        return insuranceOfferService.addInsuranceOffer(insuranceOffer) ? JsonResult.ok("报价成功") : JsonResult.error("报价失败");
    }

    /**
     * 获取报价信息
     * @return
     */
    @GetMapping
    public Map<String, Object> getInsuranceList() {
        Map<String,Object> map = new HashMap<>();
        map.put("code",200);
        map.put("data",insuranceProperties.getList());
        return map;
    }


}
